<template>
	<view class="visit" style="padding-top: 10px;">
		<view class="about">
			
			<view class="button1" style="font-size: 12px;height: 30px;line-height: 30px;" @tap="showTimePicker">{{month}}拜访情况
				<view style="width: 15px; height: 15px;background-size:contain; background-image: url(../../static/button1_bottom.png);" ></view>		
			</view>					</view>

	<view>
		<u-table border-color="white">
			<u-tr class="u-tr">
				<u-th class="u-th">本月</u-th>
				<u-th class="u-th">实际</u-th>
				<u-th class="u-th">计划</u-th>
				<u-th class="u-th">平均</u-th>
			</u-tr>
			<u-tr class="u-tr">
				<u-td class="u-td">本月合计</u-td>
				<u-td class="u-td">0</u-td>
				<u-td class="u-td">0</u-td>
				<u-td class="u-td">0</u-td>
			</u-tr>
		</u-table>
    </view>
		
		<u-picker v-model="show" mode="time" @confirm="onchangeDate"></u-picker>
	</view>

</template>

<script>
	import {
		mapMutations,
		mapState
	} from 'vuex';
	import {
		worksList
	} from '@/api/userInfo';
	import rfLoadMore from '@/components/oa-load-more/oa-load-more';
	import moment from '@/common/moment';
	import $mAssetsPath from '@/config/assets.config';
	import oaEmpty from '@/components/oa-empty';
	import {http} from '@/utils/request/index.js';
	export default {
		components: {
			rfLoadMore,
			oaEmpty
		},
		data() {
			return {
				show:false,
				month:"8月",
				activeIndex: 0,
				searchForm:{
					month:""
				},
			}
		},
		computed: {
			...mapState(['userInfo'])
		},
		async onShow(options) {
			await this.initData();
		},
		async onLoad(options) {
			this.searchForm.slsmanCode = this.userInfo.username
			this.searchForm.month = moment().format('M');
			
			
			this.month = moment().format('M月');
			await this.initData();
		},

		// 下拉刷新
		onPullDownRefresh() {
			
			this.initData('refresh');
		},
		// 加载更多
		onReachBottom() {
			// if (this.loadingType === 'nomore') return;
			// this.page++;
			// this.getworksList();
		},

		methods: {
			onchangeDate(e){
				console.log("onchangeDate",e[0])
				this.month = moment(e.timestamp).format('M月');
				this.searchForm.month = e.month
				this.loadData()
			},
			showTimePicker(){
				this.show=true
			},
			tabClick(index, name) {
				// 点击的index
				console.log(index, name);
				
				// 获取点击的数据
				console.log(this.tabs[index]);
			},
			tabArrayClick(index, name) {
				// 点击的index
				console.log(index, name);
				
				// 获取点击的数据
				console.log(this.tabsArray[index]);
			},
			bindDateChange(e) {
				this.date = e.target.value;
			},
			// 数据初始化
			async initData(type) {
				await http.get("oaPlanExecute/tongji",this.searchForm).then(r=>{
					 uni.hideLoading()
					 if(res.success){
						
					 }	
					 
					 if (type === 'refresh') {
					 	uni.stopPullDownRefresh();
					 }
					 
				}).catch(() => {
						uni.hideLoading()
						
						if (type === 'refresh') {
							uni.stopPullDownRefresh();
						}
					});
				
			},
			// 获取资料列表
			async getworksList(type) {
				if (!this.hasLogin) {
					this.loading = false;
					if (type === 'refresh') uni.stopPullDownRefresh();
					uni.removeTabBarBadge({
						index: this.$mConstDataConfig.worksIndex
					});
					return;
				}
				await this.$http.get(`${worksList}`, {
						page: this.page
					}).then(r => {
						this.loading = false;
						if (type === 'refresh') {
							uni.stopPullDownRefresh();
						}
						this.loadingType = r.data.length === 10 ? 'more' : 'nomore';
						this.worksList = [...this.worksList, ...r.data];
					})
					.catch(() => {
						this.loading = false;
						if (type === 'refresh') {
							uni.stopPullDownRefresh();
						}
					});
			},
			navToLogin(route) {
				this.$mRouter.push({
					route
				});
			},
			navTo(route) {
				this.$mRouter.push({
					route
				});
			}
		}
	};


</script>

<style lang="scss" scoped>
	
	.button1 {
		display: inline-block;
		height: 45px;
		border-radius: 100px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 16px;
		font-weight: 600;
		color: #000000;height: 20px;line-height: 20px;padding: 2px 6px;background-color: #f5faf9;border: none;
		background: white;
	}
	.title-in1line{
		font-weight: bolder;
		font-size: 15px;
	}
	
	.uni-media-list-text-bottom {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	}

	.date {
		display: inline-block;
		width: 180upx;
		font-size: $font-sm + 1upx;
		color: $font-color-base;
	}
	.tit {
		width: 120upx;
		font-size: $font-sm + 1upx;
		text-align:center;
	    color: $font-color-base;
		border-radius:25px;
		-moz-border-radius:25px;
	}
	page {
		background-color: $page-color-base;
	}
	
    .input-item {
		display: inline-block;
		
		// width: 15%;
	}
	.visit {
		.uni-media-list-logo {
			width: 180rpx;
			height: 140rpx;
		}

		.uni-media-list-body {
			height: auto;
			justify-content: space-around;
		}

		.uni-media-list-text-top {
			height: 74rpx;
			font-size: 28rpx;
			overflow: hidden;
		}

		.uni-media-list-text-bottom {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
		}

		.add-round {
			position: fixed;
			z-index: 999;
			right: 30rpx;
			bottom: 30rpx;
			border-radius: 50%;
			width: 120rpx;
			height: 120rpx;
			color: #fff;
			text-align: center;
			line-height: 120rpx;
			font-weight: 100;
			font-size: 80rpx;
		}

		.notify-list {
			margin-top: 20upx;
			
			.read {
				text-align: right;
				margin-right: $spacing-base;
				margin-top: $spacing-base;
				margin-bottom: $spacing-sm;

				text {
					margin-left: $spacing-base;
				}
			}

			.row {
				width: calc(100%);
				height: calc(22vw + 40upx);
				
				border-radius: 15upx;
				box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.1);
				display: flex;
				align-items: center;
				position: relative;
				overflow: hidden;
				z-index: 4;
				border: 0;

				.menu {
					.iconfont {
						color: #fff;
						font-size: 60upx;
					}

					position: absolute;
					width: 29%;
					height: 100%;
					right: 0;
					display: flex;
					justify-content: center;
					align-items: center;
					color: #fff;
					z-index: 2;
				}
				
				.carrier {
					@keyframes showMenu {
						0% {
							transform: translateX(0);
						}

						100% {
							transform: translateX(-30%);
						}
					}

					@keyframes closeMenu {
						0% {
							transform: translateX(-30%);
						}

						100% {
							transform: translateX(0);
						}
					}

					&.open {
						animation: showMenu 0.25s linear both;
					}

					&.close {
						animation: closeMenu 0.15s linear both;
					}

					background-color: #fff;
					position: absolute;
					width: 100%;
					padding: 0 0;
					height: 100%;
					z-index: 3;
					display: flex;
					align-items: center;
				}
			}

			.notify-wrapper {
				background-color: $color-white;
				width: 100%;
				padding: $spacing-base $spacing-lg $spacing-base $spacing-lg;
				margin: $spacing-base 0 0;
				border-radius: 15upx;
				position: relative;

				.title {
					font-size: $font-lg;
					color: $font-color-dark;
					font-weight: 500;
					margin: 0 0 $spacing-sm;
				}

				.content {
					font-size: $font-sm;
					color: $font-color-base;
					height: 75upx;
					line-height: 36upx;
				}

				.time {
					font-size: $font-base;
					color: $font-color-light;
				}

				.type {
					position: absolute;
					top: 26upx;
					left: -10upx;
					border: none;
					font-size: $font-sm;
					opacity: 0.8;
				}

				.un-read {
					display: inline-block;
					width: 12upx;
					height: 12upx;
					border-radius: 50%;
					position: absolute;
					top: 32upx;
					right: 30upx;
				}
			}
		}

		.notify-empty {
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			height: 100vh;
			padding-bottom: 100upx;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
			background: #fff;

			.iconfont {
				font-size: $font-lg + 100upx;
			}

			.empty-tips {
				display: flex;
				font-size: $font-sm + 2upx;
				color: $font-color-disabled;

				.navigator {
					margin-left: 16upx;
				}
			}
		}

		.works-empty {
			position: fixed;
			left: 0;
			top: 0;
			width: 100%;
			height: 100vh;
			padding-bottom: 100upx;
			display: flex;
			justify-content: center;
			flex-direction: column;
			align-items: center;
			background: #fff;

			.iconfont {
				font-size: $font-lg + 100upx;
			}

			.empty-tips {
				display: flex;
				font-size: $font-sm + 2upx;
				color: $font-color-disabled;

				.navigator {
					margin-left: 16upx;
				}
			}
		}
	}
</style>
